<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <img id="slide" src="" alt="" />
</body>
<script>
    var images = []
    var time = 3000
    var i = 0
    images[0] = 'img/1.jpg'
    images[1] = 'img/2.jpg'
    images[2] = 'img/3.jpg'
    images[3] = 'img/4.jpg'
    images[4] = 'img/5.jpg'
    console.log(images)

    function changeImg() {
        var a = document.getElementById('slide')
        a.src = images[i]
        if (i < images.length-1) {
            i++
        } else {
            i = 0
        }
        setTimeout('changeImg()',time)
    }
    window.onload = changeImg
</script>
<style>

</style>

</html>